package cloud.tianai.mate.captcha.generator.impl;

import java.awt.*;
import java.awt.image.BufferedImage;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;

public class Demo4 {

    public static void main(String[] args) {
        int width = 600; // 图像宽度
        int height = 360; // 图像高度
        int mosaicSizeX = 64; // 马赛克块大小
        int mosaicSizeY = 32; // 马赛克块大小

        BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
        Graphics g = image.getGraphics();
        g.setColor(new Color(147, 145, 145));
        g.fillRect(0, 0, width, height);

        ThreadLocalRandom random = ThreadLocalRandom.current();
        for (int i = 0; i < 10; i++) {
            // 绘制红色圆圈
            g.setColor(getRandomColor());
            int wh = random.nextInt(150, 300);
            g.fillOval(random.nextInt(width), random.nextInt(height), wh , wh);

//            // 绘制绿色矩形
//            g.setColor(Color.GREEN);
//            g.fillRect(200, 50, 100, 100);
//
//            // 绘制蓝色三角形
//            g.setColor(Color.BLUE);
//            g.fillPolygon(new int[]{400, 450, 350}, new int[]{50, 150, 150}, 3);
        }

        System.out.println(111);
    }

    private static Color getRandomColor() {
        List<Color> list = Arrays.asList(
                new Color(254, 220, 172),
                new Color(218, 196, 220),
                new Color(252, 249, 207),
                new Color(181, 203, 225),
                new Color(251, 182, 180),
                new Color(227, 209, 184)
        );
        return list.get((int) (Math.random() * list.size()));
    }

}
